home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48hor1 / syzygy.src < prev    next >
Text File  |  1990-10-29  |  28KB  |  844 lines

  1. (Comp.sys.handhelds)
  2. Item: 1037 by rtrevino at cpocd5.intel.com
  3. Author: [Roy Trevino]
  4.   Subj: syzygy v0.1 - source code
  5.   Date: Mon Nov 05 1990 09:06 
  6.  
  7. Several people have requested the source to syzygy, so here it is.
  8. Actually it's the listing file.  It would have been posted sooner,
  9. but I wanted to add *some* comments at least, etc.  Hopefully whoever
  10. sent mail to me will see it.  Anyways, I guess we can all expect to
  11. see tons more chip-48 programs posted now, as there is so much interest
  12. in source code!   :-)  They are actually quite easy to write.
  13.  
  14. Roy
  15.  
  16. PS - has anyone used the shift instructions in chip48?   The documentation
  17. does not correlate with the "opcodes".    How do they really work?
  18.  
  19. ======================================================================
  20.  
  21. --> PASS 1
  22. ****** 0 error(s) detected in pass 1 ******
  23. --> PASS 2
  24.      ;
  25.      ;   SYZYGY is (c) copyright 1990 by Roy Trevino (RTT)
  26.      ;
  27.      ;   Noncommercial distribution allowed, provided that this
  28.      ;   copyright message is preserved, and any modified versions
  29.      ;   are clearly marked as such.
  30.      ;
  31.      ;   SYZYGY, via CHIP-48, makes use of undocumented low-level features
  32.      ;   of the HP48SX calculator, and may or may not cause loss of data,
  33.      ;   excessive battery drainage, and/or damage to the calculator
  34.      ;   hardware.  The Author takes no responsibility whatsoever for
  35.      ;   any damage caused by the use of this program.
  36.      ;
  37.      ;   THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
  38.      ;   IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  39.      ;   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  40.      ;   PURPOSE.
  41.      ;
  42.     
  43. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  44.      ;
  45.      ;  Register usage (primary usage, may be others):
  46.      ;
  47.      ; v0 - scratch
  48.      ; v1 - x position of head
  49.      ; v2 - y position of head
  50.      ; v3 - current direction of head
  51.      ; v4 - pointer to segment table entry for head
  52.      ; v5 - previous direction of head
  53.      ; v6 - x position of tail
  54.      ; v7 - y position of tail
  55.      ; v8 - direction of tail
  56.      ; v9 - pointer to segment table entry for tail
  57.      ; va - count of points being added to length
  58.      ; vb - x position of target
  59.      ; vc - y position of target
  60.      ; vd - flags if target is on or off
  61.      ; ve - random on time for target
  62.      ; vf - carry/borrow/collision detect
  63.      ;
  64. ==== 0003  up:       equ     #3            ; (9) key for up
  65. ==== 0006  down:     equ     #6            ; (6) key for down
  66. ==== 0007  left:     equ     #7            ; (1) key for left
  67. ==== 0008  right:    equ     #8            ; (2) key for right
  68.  
  69.      ;
  70.      ;  Start of a circular table to track each segment of the syzygy,
  71.      ;  which consists of a direction and a length.
  72.      ;
  73.      ;  The start of the table is at #800 instead of a label at the bottom
  74.      ;  of the program (ie.  base:  end) because it seems to run faster
  75.      ;  that way.
  76.      ;
  77. ==== 0800  base:     equ     #800          ; base of segment table
  78.  
  79. 0200      copyright:                  ; copyright notice
  80. 0200 1212        jp        _start
  81. 0202 8d8d        dw        #8d8d           ; ->
  82. 0204 20a9        dw        #20a9           ; (c)
  83. 0206 3139        dw        #3139           ; 19
  84. 0208 3930        dw        #3930           ; 90
  85. 020a 2052        dw        #2052           ;    R
  86. 020c 5454        dw        #5454           ; TT
  87. 020e 208e        dw        #208e           ; <-
  88. 0210 8e00        dw        #8e00
  89. 0212      start:
  90. 0212 24b6        call    _drawbord
  91. 0214 24da        call    _drawtitle
  92. 0216      waitkp1:
  93. 0216 600f        ld        v0,#f           ; wait for (+) (keep border)
  94. 0218 e0a1        sknp    v0
  95. 021a 1224        jp        _starty
  96. 021c 600e        ld        v0,#e           ; wait for (-) (borderless)
  97. 021e e0a1        sknp    v0
  98. 0220 1228        jp        _startn
  99. 0222 1216        jp        _waitkp1
  100. 0224      starty:
  101. 0224 24da        call    _drawtitle        ; erase title (keep border)
  102. 0226 122c        jp        _initgame
  103. 0228      startn:
  104. 0228 00e0        cls             ; erase everything (borderless)
  105. 022a 122c        jp        _initgame
  106.      ;
  107.      ;  initialization routines
  108.      ;
  109. 022c      initgame:
  110.      ;
  111.      ;  initial head position near middle of screen
  112.      ;
  113. 022c c11f        rnd     v1,#1f       ; x-pos = rnd(16,47)
  114. 022e 7110        add     v1,#10
  115. 0230 c20f        rnd     v2,#f        ; y-pos = rnd(8,23)
  116. 0232 7208        add     v2,#8
  117. 0234 c303        rnd     v3,#3        ; direction = rnd(0,3)
  118. 0236 8530        ld        v5,v3           ; last head direction
  119.      ;
  120.      ;  compute initial tail position
  121.      ;
  122. 0238 8610        ld        v6,v1           ; start out same as head
  123. 023a 8720        ld        v7,v2
  124. 023c 8830        ld        v8,v3           ; tail direction
  125.  
  126. 023e 4800        sne     v8,#0        ; up
  127. 0240 7701        add     v7,#1
  128. 0242 4801        sne     v8,#1        ; down
  129. 0244 77ff        add     v7,#ff
  130. 0246 4802        sne     v8,#2        ; left
  131. 0248 7601        add     v6,#1
  132. 024a 4803        sne     v8,#3        ; right
  133. 024c 76ff        add     v6,#ff
  134.      ;
  135.      ;  draw initial syzygy, save initial segment to table
  136.      ;
  137. 024e a54c        ld        i,_dot
  138. 0250 d121        drw     v1,v2,#1          ; draw head
  139. 0252 d671        drw     v6,v7,#1          ; draw tail
  140.  
  141. 0254 64f0        ld        v4,#f0          ; init ptr to head vector
  142. 0256 69f1        ld        v9,#f1          ; init ptr to tail vector
  143.  
  144. 0258 a800        ld        i,_base         ; save direction
  145. 025a f41e        add     i,v4
  146. 025c 8030        ld        v0,v3
  147. 025e f055        ld        [i],v0
  148. 0260 7401        add     v4,#1        ; increment head ptr
  149. 0262 a800        ld        i,_base         ; save segment count
  150. 0264 f41e        add     i,v4
  151. 0266 6001        ld        v0,#1
  152. 0268 f055        ld        [i],v0
  153.  
  154.      ;
  155.      ;  compute coordinates and value of first target
  156.      ; plus set up flag and time until target
  157.      ;
  158. 026a 2522        call    _rndtarg
  159.  
  160.  
  161. 026c 6a00        ld        va,#0           ; additional length
  162.  
  163.      ;
  164.      ; initial addition to syzygy for test purposes
  165.      ;
  166. 026e 7a00        add     va,#0
  167.      ;
  168.      ;  main loop begins here
  169.      ;
  170. 0270      loop:
  171.  
  172. 0270      chktarg:
  173. 0270 f007        ld        v0,dt           ; check if a target is due
  174. 0272 3000        se        v0,#0
  175. 0274 129c        jp        _endtarg
  176. 0276 3d00        se        vd,#0
  177. 0278 1294        jp        _targoff
  178.  
  179. 027a 6000        ld        v0,#0           ; draw target
  180. 027c f029        ld        f,v0
  181. 027e dbc5        drw     vb,vc,#5
  182.  
  183. 0280 3f01        se        vf,#1           ; if on body, erase immediately
  184. 0282 128c        jp        _targon
  185. 0284 dbc5        drw     vb,vc,#5
  186. 0286 2522        call    _rndtarg          ; set up new target
  187. 0288 f015        ld        dt,v0           ; no delay though
  188. 028a 129c        jp        _endtarg        ; process at least one move
  189.  
  190. 028c      targon:
  191. 028c fe15        ld        dt,ve           ; set up on-time
  192. 028e 6d01        ld        vd,#1           ; set flag to denote on
  193. 0290 6e00        ld        ve,#0           ; number of points unless hit
  194. 0292 129c        jp        _endtarg
  195.  
  196. 0294      targoff:
  197. 0294 80e0        ld        v0,ve           ; erase old target
  198. 0296 f029        ld        f,v0
  199. 0298 dbc5        drw     vb,vc,#5
  200.  
  201. 029a 2522        call    _rndtarg          ; set up new target
  202. 029c      endtarg:
  203.  
  204.  
  205. 029c      chkkeys:
  206. 029c 6003        ld        v0,_up          ; check for user input
  207. 029e e0a1        sknp    v0
  208. 02a0 6300        ld        v3,#0           ; new direction
  209.  
  210. 02a2 6006        ld        v0,_down
  211. 02a4 e0a1        sknp    v0
  212. 02a6 6301        ld        v3,#1
  213.  
  214. 02a8 6007        ld        v0,_left
  215. 02aa e0a1        sknp    v0
  216. 02ac 6302        ld        v3,#2
  217.  
  218. 02ae 6008        ld        v0,_right
  219. 02b0 e0a1        sknp    v0
  220. 02b2 6303        ld        v3,#3
  221.      ;
  222.      ;  compute next head position
  223.      ;
  224. 02b4 4300        sne     v3,#0        ; up
  225. 02b6 72ff        add     v2,#ff
  226. 02b8 4301        sne     v3,#1        ; down
  227. 02ba 7201        add     v2,#1
  228. 02bc 4302        sne     v3,#2        ; left
  229. 02be 71ff        add     v1,#ff
  230. 02c0 4303        sne     v3,#3        ; right
  231. 02c2 7101        add     v1,#1
  232.      ;
  233.      ;  draw next head position
  234.      ;
  235. 02c4 a54c        ld        i,_dot
  236. 02c6 d121        drw     v1,v2,#1
  237.      ;
  238.      ;  check for collision
  239.      ;
  240. 02c8      chkcoll:
  241. 02c8 3f01        se        vf,#1
  242. 02ca 1324        jp        _chkhead
  243.      ;
  244.      ;  if collision is due to target, add points (else die)
  245.      ; this also means no doubling back on self
  246.      ;
  247. 02cc 3d01        se        vd,#1           ; check if target is even on
  248. 02ce 1388        jp        _endgame
  249.  
  250. 02d0 603f        ld        v0,#3f          ; mask off extra x and y bits
  251. 02d2 8102        and     v1,v0
  252. 02d4 601f        ld        v0,#1f
  253. 02d6 8202        and     v2,v0
  254.  
  255. 02d8 80b0        ld        v0,vb           ; check if < target on left
  256. 02da 8017        subn    v0,v1
  257. 02dc 3f01        se        vf,#1
  258. 02de 1388        jp        _endgame
  259.  
  260. 02e0 80b0        ld        v0,vb           ; check if > target on right
  261. 02e2 7003        add     v0,#3
  262. 02e4 8015        sub     v0,v1
  263. 02e6 3f01        se        vf,#1
  264. 02e8 1388        jp        _endgame
  265.  
  266. 02ea 80c0        ld        v0,vc           ; check if < target on top
  267. 02ec 8027        subn    v0,v2
  268. 02ee 3f01        se        vf,#1
  269. 02f0 1388        jp        _endgame
  270.  
  271. 02f2 80c0        ld        v0,vc           ; check if > target on bottom
  272. 02f4 7004        add     v0,#4
  273. 02f6 8025        sub     v0,v2
  274. 02f8 3f01        se        vf,#1
  275. 02fa 1388        jp        _endgame
  276.      ;
  277.      ;  if made it this far, add points, erase target, etc
  278.      ;
  279. 02fc 6004        ld        v0,#4           ; beep (actually, a "bip")
  280. 02fe f018        ld        st,v0
  281.  
  282. 0300 ce07        rnd     ve,#7        ; award rnd(2,9) points
  283. 0302 7e02        add     ve,#2        ;
  284. 0304 8ae4        add     va,ve        ; add points
  285.  
  286. 0306 a54c        ld        i,_dot          ; temporarily erase head
  287. 0308 d121        drw     v1,v2,#1
  288. 030a 6000        ld        v0,#0           ; erase target
  289. 030c f029        ld        f,v0
  290. 030e dbc5        drw     vb,vc,#5
  291. 0310 80e0        ld        v0,ve           ; draw points instead
  292. 0312 f029        ld        f,v0
  293. 0314 dbc5        drw     vb,vc,#5
  294.  
  295. 0316 6030        ld        v0,#30          ; delay for a while
  296. 0318 f015        ld        dt,v0
  297. 031a      targwait:
  298. 031a f007        ld        v0,dt
  299. 031c 3000        se        v0,#0
  300. 031e 131a        jp        _targwait
  301.  
  302. 0320 a54c        ld        i,_dot
  303. 0322 d121        drw     v1,v2,#1          ; redraw head
  304.      ;
  305.      ;  if direction changed, create a new segment record
  306.      ;
  307. 0324      chkhead:
  308. 0324 9350        sne     v3,v5
  309. 0326 133e        jp        _conthead
  310.  
  311. 0328 7401        add     v4,#1        ; new segment record
  312. 032a a800        ld        i,_base
  313. 032c f41e        add     i,v4
  314. 032e 8030        ld        v0,v3           ; save direction
  315. 0330 f055        ld        [i],v0
  316. 0332 7401        add     v4,#1        ; point to counter
  317. 0334 a800        ld        i,_base         ; initialize segment count to
  318. 0
  319. 0336 f41e        add     i,v4
  320. 0338 6000        ld        v0,#0
  321. 033a f055        ld        [i],v0
  322.  
  323. 033c 8530        ld        v5,v3           ; reset previous direction
  324.  
  325. 033e      conthead:
  326. 033e a800        ld        i,_base         ; simply add to current record
  327. 0340 f41e        add     i,v4
  328. 0342 f065        ld        v0,[i]
  329. 0344 7001        add     v0,#1        ; increment head count
  330. 0346 f055        ld        [i],v0
  331.      ;
  332.      ;  don't erase tail if adding points to length
  333.      ;
  334. 0348      chkpts:
  335. 0348 4a00        sne     va,#0
  336. 034a 1358        jp        _contpts        ; if pts = 0, continue normally
  337.  
  338. 034c 600c        ld        v0,#c           ; delay just a little to compensate
  339. 034e      delhead:
  340. 034e 70ff        add     v0,#ff
  341. 0350 3000        se        v0,#0
  342. 0352 134e        jp        _delhead
  343.  
  344. 0354 7aff        add     va,#ff       ; decrement and loop
  345. 0356 1270        jp        _loop
  346.  
  347. 0358      contpts:
  348.      ;
  349.      ;  erase last tail position
  350.      ;
  351. 0358 a54c        ld        i,_dot
  352. 035a d671        drw     v6,v7,#1
  353.  
  354.      ;
  355.      ;  compute next tail position
  356.      ;
  357. 035c 4800        sne     v8,#0        ; up
  358. 035e 77ff        add     v7,#ff
  359. 0360 4801        sne     v8,#1        ; down
  360. 0362 7701        add     v7,#1
  361. 0364 4802        sne     v8,#2        ; left
  362. 0366 76ff        add     v6,#ff
  363. 0368 4803        sne     v8,#3        ; right
  364. 036a 7601        add     v6,#1
  365.  
  366. 036c      chktail:
  367. 036c a800        ld        i,_base         ; get tail segment record
  368. 036e f91e        add     i,v9
  369. 0370 f065        ld        v0,[i]
  370. 0372 70ff        add     v0,#ff       ; decrement tail count
  371. 0374 f055        ld        [i],v0          ; save
  372. 0376 3000        se        v0,#0           ; if zero, get new record
  373. 0378 1270        jp        _loop
  374.  
  375. 037a 7901        add     v9,#1        ; new segment record
  376. 037c a800        ld        i,_base         ; get new direction
  377. 037e f91e        add     i,v9
  378. 0380 f065        ld        v0,[i]
  379. 0382 8800        ld        v8,v0
  380. 0384 7901        add     v9,#1        ; point to new count
  381.      ;
  382.      ;  end of main loop
  383.      ;
  384. 0386 1270        jp        _loop
  385.      ;
  386.      ;  endgame routines
  387.      ;
  388. 0388      endgame:
  389. 0388 600d        ld        v0,#d           ; beep
  390. 038a f018        ld        st,v0
  391.  
  392. 038c 600b        ld        v0,#b           ; wait for (space) keypress
  393. 038e e09e  endkp:    skp     v0
  394. 0390 138e        jp        _endkp
  395.      ;
  396.      ;  finish up tail to count points: digits are in vd:vc:vb format
  397.      ;  note that it is theoretically possible to get 64*32=2048 points,
  398.      ;  while three digits will only hold 999.  Unlikely but possible.
  399.      ;
  400. 0392 6b01        ld        vb,#1           ; one's digit
  401. 0394 6c00        ld        vc,#0           ; ten's digit
  402. 0396 6d00        ld        vd,#0           ; hundred's digit
  403.  
  404. 0398      endtail:
  405.      ;
  406.      ;  increment score
  407.      ;
  408. 0398 7b01        add     vb,#1
  409. 039a 3b0a        se        vb,#a
  410. 039c 13aa        jp        _endtailcont
  411. 039e 6b00        ld        vb,#0
  412. 03a0 7c01        add     vc,#1
  413. 03a2 3c0a        se        vc,#a
  414. 03a4 13aa        jp        _endtailcont
  415. 03a6 6c00        ld        vc,#0
  416. 03a8 7d01        add     vd,#1
  417.      ;
  418.      ;  compute next tail position to add up score
  419.      ;
  420. 03aa      endtailcont:
  421. 03aa a54c        ld        i,_dot          ; erase last tail position
  422. 03ac d671        drw     v6,v7,#1
  423.  
  424. 03ae 4800        sne     v8,#0        ; up
  425. 03b0 77ff        add     v7,#ff
  426. 03b2 4801        sne     v8,#1        ; down
  427. 03b4 7701        add     v7,#1
  428. 03b6 4802        sne     v8,#2        ; left
  429. 03b8 76ff        add     v6,#ff
  430. 03ba 4803        sne     v8,#3        ; right
  431. 03bc 7601        add     v6,#1
  432.  
  433. 03be a800        ld        i,_base         ; get tail segment record
  434. 03c0 f91e        add     i,v9
  435. 03c2 f065        ld        v0,[i]
  436. 03c4 70ff        add     v0,#ff       ; decrement tail count
  437. 03c6 f055        ld        [i],v0          ; save
  438. 03c8 3000        se        v0,#0           ; if zero, get new record
  439. 03ca 1398        jp        _endtail
  440.  
  441. 03cc 9940        sne     v9,v4        ; done when pointers are equal
  442. 03ce 13de        jp        _drawscore
  443.  
  444. 03d0 7901        add     v9,#1        ; new segment record
  445. 03d2 a800        ld        i,_base         ; get new direction
  446. 03d4 f91e        add     i,v9
  447. 03d6 f065        ld        v0,[i]
  448. 03d8 8800        ld        v8,v0
  449. 03da 7901        add     v9,#1        ; point to new count
  450. 03dc 1398        jp        _endtail
  451.      ;
  452.      ;  draw score
  453.      ;
  454. 03de      drawscore:
  455. 03de 00e0        cls
  456. 03e0 6611        ld        v6,#11          ; draw border
  457. 03e2 6709        ld        v7,#9
  458. 03e4 682f        ld        v8,#2f
  459. 03e6 6917        ld        v9,#17
  460. 03e8 a552        ld        i,_vbar
  461. 03ea d67e        drw     v6,v7,#e
  462. 03ec d87e        drw     v8,v7,#e
  463. 03ee 77ff        add     v7,#ff
  464. 03f0 a54e        ld        i,_hbar
  465. 03f2 d671        drw     v6,v7,#1
  466. 03f4 d691        drw     v6,v9,#1
  467. 03f6 7608        add     v6,#8
  468. 03f8 d671        drw     v6,v7,#1
  469. 03fa d691        drw     v6,v9,#1
  470. 03fc 7608        add     v6,#8
  471. 03fe d671        drw     v6,v7,#1
  472. 0400 d691        drw     v6,v9,#1
  473. 0402 7608        add     v6,#8
  474. 0404 a550        ld        i,_hbar2
  475. 0406 d671        drw     v6,v7,#1
  476. 0408 d691        drw     v6,v9,#1
  477.  
  478. 040a a59e        ld        i,_sc           ; show score (not high score yet)
  479. 040c 6613        ld        v6,#13
  480. 040e 6711        ld        v7,#11
  481. 0410 249a        call    _showscore
  482.      ;
  483.      ;  figure out if it's the high score, save it if it is
  484.      ;
  485. 0412      checkhigh:
  486. 0412 a5ae        ld        i,_high         ; recover old high score into v3v2v1
  487. 0414 f365        ld        v3,[i]
  488.  
  489. 0416 93d0        sne     v3,vd        ; if =, check next digit
  490. 0418 1424        jp        _conthigh1
  491. 041a 8030        ld        v0,v3           ; if borrow, it's a new high score!
  492. 041c 80d5        sub     v0,vd
  493. 041e 3f01        se        vf,#1
  494. 0420 143a        jp        _savehigh
  495. 0422 1444        jp        _drawhigh
  496. 0424      conthigh1:
  497. 0424 92c0        sne     v2,vc        ; etc. as above for other digits
  498. 0426 1432        jp        _conthigh2
  499. 0428 8020        ld        v0,v2
  500. 042a 80c5        sub     v0,vc
  501. 042c 3f01        se        vf,#1
  502. 042e 143a        jp        _savehigh
  503. 0430 1444        jp        _drawhigh
  504. 0432      conthigh2:
  505. 0432 8010        ld        v0,v1
  506. 0434 80b5        sub     v0,vb
  507. 0436 3f00        se        vf,#0
  508. 0438 1444        jp        _drawhigh
  509.  
  510. 043a      savehigh:
  511. 043a a5ae        ld        i,_high
  512. 043c 83d0        ld        v3,vd           ; save new high score
  513. 043e 82c0        ld        v2,vc
  514. 0440 81b0        ld        v1,vb
  515. 0442 f355        ld        [i],v3
  516.      ;
  517.      ;  draw the high score
  518.      ;
  519. 0444      drawhigh:
  520. 0444 a5ae        ld        i,_high
  521. 0446 f365        ld        v3,[i]
  522. 0448 6613        ld        v6,#13
  523. 044a 77f9        add     v7,#f9
  524. 044c 8d30        ld        vd,v3
  525. 044e 8c20        ld        vc,v2
  526. 0450 8b10        ld        vb,v1
  527. 0452 a5a4        ld        i,_hi
  528. 0454 249a        call    _showscore
  529.      ;
  530.      ;  random memory wasting stuff goes here
  531.      ;
  532. 0456      waitkp2:
  533.  
  534. 0456 c13f        rnd     v1,#3f       ; get random position
  535. 0458 c21f        rnd     v2,#1f
  536.  
  537. 045a 600d        ld        v0,#d           ; check left
  538. 045c 8015        sub     v0,v1
  539. 045e 3f00        se        vf,#0
  540. 0460 147c        jp        _drawrand
  541.  
  542. 0462 6030        ld        v0,#30          ; check right
  543. 0464 8017        subn    v0,v1
  544. 0466 3f00        se        vf,#0
  545. 0468 147c        jp        _drawrand
  546.  
  547. 046a 6003        ld        v0,#3           ; check top
  548. 046c 8025        sub     v0,v2
  549. 046e 3f00        se        vf,#0
  550. 0470 147c        jp        _drawrand
  551.  
  552. 0472 6018        ld        v0,#18          ; check bottom
  553. 0474 8027        subn    v0,v2
  554. 0476 3f00        se        vf,#0
  555. 0478 147c        jp        _drawrand
  556. 047a 1482        jp        _chkkp2
  557.  
  558. 047c      drawrand:
  559. 047c c30f        rnd     v3,#0f       ; draw random number
  560. 047e f329        ld        f,v3
  561. 0480 d125        drw     v1,v2,#5
  562.  
  563. 0482      chkkp2:
  564. 0482 600f        ld        v0,#f           ; check for keypress
  565. 0484 e0a1        sknp    v0
  566. 0486 1490        jp        _conty
  567. 0488 600e        ld        v0,#e
  568. 048a e0a1        sknp    v0
  569. 048c 1496        jp        _contn
  570. 048e 1456        jp        _waitkp2
  571.  
  572. 0490 00e0  conty:    cls
  573. 0492 24b6        call    _drawbord
  574. 0494 122c        jp        _initgame
  575. 0496 00e0  contn:    cls
  576. 0498 122c        jp        _initgame
  577.      ;
  578.      ;  function showscore:
  579.      ; digits in vd:vc:vb, descriptor in i, initial coords in v6,v7
  580.      ;
  581. 049a      showscore:
  582. 049a d675        drw     v6,v7,#5
  583. 049c a5aa        ld        i,_col
  584. 049e 7602        add     v6,#2
  585. 04a0 d674        drw     v6,v7,#4
  586. 04a2 fd29        ld        f,vd
  587. 04a4 760a        add     v6,#a
  588. 04a6 d675        drw     v6,v7,#5
  589. 04a8 fc29        ld        f,vc
  590. 04aa 7605        add     v6,#5
  591. 04ac d675        drw     v6,v7,#5
  592. 04ae fb29        ld        f,vb
  593. 04b0 7605        add     v6,#5
  594. 04b2 d675        drw     v6,v7,#5
  595.  
  596. 04b4 00ee        ret
  597.      ;
  598.      ;  function drawbord:
  599.      ; draw border, try to do it fast
  600.      ;
  601. 04b6      drawbord:
  602. 04b6      horiz:
  603. 04b6 a54e        ld        i,_hbar
  604. 04b8 6100        ld        v1,#0           ; left
  605. 04ba 6200        ld        v2,#0           ; right
  606. 04bc 661f        ld        v6,#1f          ; lower
  607. 04be      horiz1:
  608. 04be d121        drw     v1,v2,#1          ; draw x,0
  609. 04c0 d161        drw     v1,v6,#1          ; draw x,31
  610. 04c2 7108        add     v1,#8
  611. 04c4 3140        se        v1,#40          ; same as 0
  612. 04c6 14be        jp        _horiz1
  613.  
  614. 04c8      vert:
  615. 04c8 a552        ld        i,_vbar
  616. 04ca 6201        ld        v2,#1
  617. 04cc 653f        ld        v5,#3f
  618. 04ce d12f        drw     v1,v2,#f
  619. 04d0 d52f        drw     v5,v2,#f
  620. 04d2 720f        add     v2,#f
  621. 04d4 d12f        drw     v1,v2,#f
  622. 04d6 d52f        drw     v5,v2,#f
  623.  
  624. 04d8 00ee        ret
  625.      ;
  626.      ;  function drawtitle:  draws game title
  627.      ;
  628. 04da      drawtitle:
  629. 04da 610c        ld        v1,#c
  630. 04dc 6207        ld        v2,#7
  631. 04de a562        ld        i,_s
  632. 04e0 d12a        drw     v1,v2,#a
  633. 04e2 a56c        ld        i,_y
  634. 04e4 7106        add     v1,#6
  635. 04e6 d12a        drw     v1,v2,#a
  636. 04e8 a576        ld        i,_z
  637. 04ea 7106        add     v1,#6
  638. 04ec d12a        drw     v1,v2,#a
  639. 04ee a56c        ld        i,_y
  640. 04f0 7106        add     v1,#6
  641. 04f2 d12a        drw     v1,v2,#a
  642. 04f4 a580        ld        i,_g
  643. 04f6 7106        add     v1,#6
  644. 04f8 d12a        drw     v1,v2,#a
  645. 04fa a56c        ld        i,_y
  646. 04fc 7106        add     v1,#6
  647. 04fe d12a        drw     v1,v2,#a
  648.  
  649. 0500 610e        ld        v1,#e
  650. 0502 6218        ld        v2,#18
  651. 0504 a58a        ld        i,_v
  652. 0506 d123        drw     v1,v2,#3
  653. 0508 a58e        ld        i,_vers
  654. 050a 7108        add     v1,#8
  655. 050c 72ff        add     v2,#ff
  656. 050e d124        drw     v1,v2,#4
  657. 0510 7109        add     v1,#9
  658. 0512 72fe        add     v2,#fe
  659. 0514 a592        ld        i,_r
  660. 0516 d126        drw     v1,v2,#6
  661. 0518 7106        add     v1,#6
  662. 051a 7201        add     v2,#1
  663. 051c a598        ld        i,_tt
  664. 051e d125        drw     v1,v2,#5
  665.  
  666. 0520 00ee        ret
  667.      ;
  668.      ;  function rndtarg:
  669.      ; returns coords as (vb,vc)
  670.      ; 0 in vd
  671.      ; time until target in dt
  672.      ; on-time value ve
  673.      ;
  674. 0522      rndtarg:
  675.      ;
  676.      ; x-pos = rnd(1,59)
  677.      ;
  678. 0522 6dc5        ld        vd,#c5          ; -#3b (-59d)
  679. 0524 cb3f  rndx:     rnd     vb,#3f        ; rnd (0,63)
  680. 0526 8eb0        ld        ve,vb
  681. 0528 8ed4        add     ve,vd        ; check if > 58
  682. 052a 4f01        sne     vf,#1
  683. 052c 1524        jp        _rndx           ; try again if too big
  684.  
  685. 052e 7b01        add     vb,#1
  686.      ;
  687.      ; y-pos = rnd(1,26)
  688.      ;
  689.  
  690. 0530 6de6        ld        vd,#e6          ; -#1a (-26d)
  691. 0532 cc1f  rndy:     rnd     vc,#1f
  692. 0534 8ec0        ld        ve,vc
  693. 0536 8ed4        add     ve,vd
  694. 0538 4f01        sne     vf,#1
  695. 053a 1532        jp        _rndy
  696.  
  697. 053c 7c01        add     vc,#1
  698.  
  699. 053e      rndf:
  700. 053e 6d00        ld        vd,#0           ; flag marking new target
  701.  
  702. 0540      rndd:
  703. 0540 ce3f        rnd     ve,#3f       ; random off delay (64 - 127)
  704. 0542 7e40        add     ve,#40
  705. 0544 fe15        ld        dt,ve
  706. 0546 ce3f        rnd     ve,#3f       ; random on delay (64 - 127)
  707. 0548 7e40        add     ve,#40
  708. 054a 00ee        ret
  709.  
  710. 054c 8000  dot:       dw        #8000           ; dot for syzygy
  711. 054e ff00  hbar:     dw         #ff00           ; horizontal border segment
  712. 0550 fe00  hbar2:    dw         #fe00
  713. 0552 8080  vbar:     dw         #8080           ; vertical border segment
  714. 0554 8080        dw        #8080
  715. 0556 8080        dw        #8080
  716. 0558 8080        dw        #8080
  717. 055a 8080        dw        #8080
  718. 055c 8080        dw        #8080
  719. 055e 8080        dw        #8080
  720. 0560 8080        dw        #8080
  721.      ;
  722.      ;  True memory wasting stuff goes here (but why not?)
  723.      ;
  724. 0562 1f10  s:         dw        #1f10           ; s character
  725. 0564 1010        dw        #1010
  726. 0566 1f01        dw        #1f01
  727. 0568 0101        dw        #0101
  728. 056a 011f        dw        #011f
  729. 056c 1111  y:         dw        #1111           ; y character
  730. 056e 1111        dw        #1111
  731. 0570 1f04        dw        #1f04
  732. 0572 0404        dw        #0404
  733. 0574 0404        dw        #0404
  734. 0576 1f01  z:         dw        #1f01           ; z character
  735. 0578 0202        dw        #0202
  736. 057a 0404        dw        #0404
  737. 057c 0808        dw        #0808
  738. 057e 101f        dw        #101f
  739. 0580 1f11  g:         dw        #1f11           ; g character
  740. 0582 1010        dw        #1010
  741. 0584 1013        dw        #1013
  742. 0586 1111        dw        #1111
  743. 0588 111f        dw        #111f
  744. 058a 0505  v:         dw        #0505           ; v character for version
  745. 058c 0200        dw        #0200
  746. 058e 7151  vers:     dw         #7151           ; version number characters
  747. 0590 5175        dw        #5175
  748. 0592 0c12  r:         dw        #0c12           ; R character for signature
  749. 0594 1e14        dw        #1e14
  750. 0596 1209        dw        #1209
  751. 0598 143e  tt:        dw        #143e           ; tt characters for signature
  752. 059a 1515        dw        #1515
  753. 059c 2a00        dw        #2a00
  754. 059e 7744  sc:        dw        #7744           ; sc characters for score
  755. 05a0 2414        dw        #2414
  756. 05a2 7700        dw        #7700
  757. 05a4 5752  hi:        dw        #5752           ; hi character for high score
  758. 05a6 7252        dw        #7252
  759. 05a8 5700        dw        #5700
  760. 05aa 0001  col:       dw        #0001           ; : character for scores
  761. 05ac 0001        dw        #0001
  762. 05ae 0000  high:     dw         #0000           ; high score storage
  763. 05b0 0000        dw        #0000
  764. 05b2             end             ; end at last
  765. ****** 0 error(s) detected in pass 2 ******
  766.  
  767. --> LABEL XRF
  768.  
  769.    label      value
  770. ------------ -------
  771. up           3h
  772. down         6h
  773. left         7h
  774. right        8h
  775. base          800h
  776. copyright      200h
  777. start         212h
  778. waitkp1            216h
  779. starty        224h
  780. startn        228h
  781. initgame       22ch
  782. loop          270h
  783. chktarg            270h
  784. targon        28ch
  785. targoff            294h
  786. endtarg            29ch
  787. chkkeys            29ch
  788. chkcoll            2c8h
  789. targwait       31ah
  790. chkhead            324h
  791. conthead       33eh
  792. chkpts        348h
  793. delhead            34eh
  794. contpts            358h
  795. chktail            36ch
  796. endgame            388h
  797. endkp         38eh
  798. endtail            398h
  799. endtailcont    3aah
  800. drawscore      3deh
  801. checkhigh      412h
  802. conthigh1      424h
  803. conthigh2      432h
  804. savehigh       43ah
  805. drawhigh       444h
  806. waitkp2            456h
  807. drawrand       47ch
  808. chkkp2        482h
  809. conty         490h
  810. contn         496h
  811. showscore      49ah
  812. drawbord       4b6h
  813. horiz         4b6h
  814. horiz1        4beh
  815. vert          4c8h
  816. drawtitle      4dah
  817. rndtarg            522h
  818. rndx          524h
  819. rndy          532h
  820. rndf          53eh
  821. rndd          540h
  822. dot           54ch
  823. hbar          54eh
  824. hbar2         550h
  825. vbar          552h
  826. s        562h
  827. y        56ch
  828. z        576h
  829. g        580h
  830. v        58ah
  831. vers          58eh
  832. r        592h
  833. tt            598h
  834. sc            59eh
  835. hi            5a4h
  836. col           5aah
  837. high          5aeh
  838.  
  839. --
  840.   --------------------------------------------------------------
  841.   Roy Trevino                                        Intel Corp.
  842.   E-mail: rtrevino@sedona.intel.com          Tel: (602) 554 2816
  843.   UUCP:  decwrl!apple!oliveb!orc!inews!rtrevino@sedona.intel.com
  844.